罗列所有支持的编码:ffmpeg -codecs
探测音频、视频时长:ffprobe -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 -i <file>
用 x265 压缩视频:ffmpeg -i <input-file>.mkv -vcodec libx265 -crf 28 <output-file>.mp4
ffmpeg -ss <hh>:<mm>:<ss> -t <hh>:<mm>:<ss> -i <input-file>.mkv -avoid_negative_ts 1 -codec copy <output-file>.mkv
去掉音频:ffmpeg -i <video-file> -c:v copy -an <new-video-file>
提取 mp3 音频:ffmpeg -i <video-file> -vn -acodec libmp3lame <audio-file>.mp3
合并视频文件:ffmpeg -f concat -i list.txt -c copy final.mkv
。其中 list.txt 的内容如下:
# list.txt
file 1st_part.mkv
file 2nd_part.mkv
file 3rd_part.mkv
合并音频和视频,即,把音频压进视频:
$ ls -alh
-rwxr----- 1 mj mj 53M Dec 20 08:57 audio.m4s
-rwxr----- 1 mj mj 270M Dec 20 08:58 video.m4s
$ ffmpeg -i video.m4s -i audio.m4s -c:v copy -c:a copy o.mp4
视频和图片互转,即,批量提取视频画面为图片:ffmpeg -i <video-file> -t 5 -s 1080x1080 -r 15 %3d.jpg
。其中:
图片转视频:ffmpeg -r 10 -i %2d.png <video-file>.mp4
。其中:
转 mp4 格式: ffmpeg -i <source> -codec copy <name>.mp4
wmv 转 mp4: ffmpeg -i <input-file>.wmv -c:v libx264 -crf 23 -c:a aac -q:a 100 <output-file>.mp4
rmvb 转 mp4: ffmpeg -i <input-file>.rmvb -c:v libx264 -strict -2 <output-file>.mp4